// 截图
"nodejs";
const { findColor } = require("image");
const { Color } = require('color');
const { requestScreenCapture } = require("media_projection");
const { click,currentActivity,currentPackage,performGesture,Point } = require("accessibility");
const { Point2 } = require("@autojs/opencv");
const { delay } = require("lang");

async function main() {
  const capturer = await requestScreenCapture();
  const img = await capturer.nextImage();
  console.log(img);
  const color = new Color(0xff9999); // yellow
  console.log(color)
  const point = await findColor(img,color,{threshold:4})
  console.log("color point x:"+point.x)
  console.log("color point x:"+point.y)

  click(point.x,point.y)
//   console.log(currentActivity())
//   console.log(currentPackage())
  const points = [new Point2(90,1582),new Point2(90,1449)]
  let y = 1200
  for (let index = 0; index < 20; index++) {
    y = y + 40;
    click(96, y)
    delay(1000)
  }
  delay(9000)
  click(999,97)
//   click(300,1300)
//   click(90,1582)
//   performGesture(points,1000)
}
main();